package com.zzhardy.common.model;


import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResultResponse implements Serializable {

    public static int OK = 1;// 正常数据
    public static int ER = 0;// 主动提示的错误
    public static int EX = -1;// 服务端异常

    public static ResultResponse success(Object data) {
        return new ResultResponse(data);
    }

    public static ResultResponse success(Object data, String code) {
        return new ResultResponse(data, code);
    }

    public static ResultResponse error(String message) {
        return new ResultResponse(ResultResponse.ER, message, null);
    }

    public static ResultResponse exception(String message) {
        return new ResultResponse(ResultResponse.EX, message, null);
    }

    public static ResultResponse error(String message, String code) {
        return new ResultResponse(ResultResponse.ER, message, code);
    }


    private int status;

    private Object data;

    private String message;

    private String code;

    public ResultResponse() {

    }

    public ResultResponse(Object data) {
        this.data = data;
        this.status = ResultResponse.OK;
    }

    public ResultResponse(Object data, String code) {
        this.data = data;
        this.code = code;
    }

    public ResultResponse(int status, String message, String code) {
        this.message = message;
        this.status = status;
        this.code = code;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
